<?php

?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css">
		<link rel="stylesheet" type="text/css" href="../css/bootstrap-theme.min.css">
		<script type="text/javascript" src="../js/jquery-3.1.1.js"></script>
		<script type="text/javascript" src="../js/bootstrap.min.js"></script>
	</head>
<body>
<?php
	session_start();
	if(isset($_SESSION['username'])){
?>
	<div class="container">
	<div class="row clearfix">
		<div class="col-md-12 column">
			<ul class="nav nav-tabs" style="padding: 2%;">
<?php
	if($_SESSION['role']>='1'){
?>
				<li>
					<a href="#" data-toggle="dropdown" class="dropdown-toggle">查看信息<strong class="caret"></strong></a>
					<ul class="dropdown-menu">
						<li>
							 <a href="../ck/ckbks.php">本科生</a>
						</li>
						<li>
							 <a href="../ck/ckyjs.php">研究生</a>
						</li>
						<li>
							 <a href="../ck/ckbss.php">博士生</a>
						</li>
					</ul>
				</li>
<?php
	}
?>
<?php
	if($_SESSION['role']>='2'){
?>
				<li>
					<a href="#" data-toggle="dropdown" class="dropdown-toggle">预修改信息<strong class="caret"></strong></a>
					<ul class="dropdown-menu">
						<li>
							 <a href="../yxg/yxgbks.php">本科生</a>
						</li>
						<li>
							 <a href="../yxg/yxgyjs.php">研究生</a>
						</li>
						<li>
							 <a href="../yxg/yxgbss.php">博士生</a>
						</li>
					</ul>
				</li>
<?php
	}
?>
<?php
	if($_SESSION['role']>='3'){
?>
				<li>
					<a href="#" data-toggle="dropdown" class="dropdown-toggle">预修改信息审核<strong class="caret"></strong></a>
					<ul class="dropdown-menu">
						<li>
							 <a href="../check/checkbks.php">本科生</a>
						</li>
						<li>
							 <a href="../check/checkyjs.php">研究生</a>
						</li>
						<li>
							 <a href="#">博士生</a>
						</li>
					</ul>
				</li>
<?}
if($_SESSION['role']>='4'){
?>
				<li>
					<a href="#" data-toggle="dropdown" class="dropdown-toggle">直接修改信息<strong class="caret"></strong></a>
					<ul class="dropdown-menu">
						<li>
							 <a href="../xg/xgbks.php">本科生</a>
						</li>
						<li>
							 <a href="../xg/xgyjs.php">研究生</a>
						</li>
						<li>
							 <a href="../xg/xgbss.php">博士生</a>
						</li>
					</ul>
				</li>
<?php
	}
?>
				<li class="dropdown pull-right">
					 <a href="#" data-toggle="dropdown" class="dropdown-toggle">用户<strong class="caret"></strong></a>
					<ul class="dropdown-menu">
						<li>
							 <a href="#">更改密码</a>
						</li>
						<li class="divider">
						</li>
						<li>
							 <a href="../logout.php">注销</a>
						</li>
					</ul>
				</li>
			</ul>
			<ul class="breadcrumb">
				<li>
					 预修改信息审核
				</li>
				<li class="active">
					本科生
				</li>
			</ul>
<?
include_once("../conn.php");
if($_SERVER["REQUEST_METHOD"] == "POST"){
	$ch = $_POST["change"];
	$iid = $_POST["iid"];
	$message = $_POST["message"];
	$changeSql = "update bachelor set xg=0 where xh='$iid'";
	mysql_query($changeSql);
	if($message=="pass")
	{
		$zzd = mysql_query("SELECT * FROM bkzd");
		$sql = "update bachelor set";
		$i = 0;
		while($row = mysql_fetch_array($zzd))
		{
			if($row['rank']<=1||$row['rank']>=14)
				continue;
			if($row['rank']==2)
			{
				$z = $row['zd'];
				$sql = $sql." $z=$ch[$i]";
				//echo $sql;
				$i++;
				continue;
			}
			$z = $row['zd'];
			if($z=='bz'){
				$sql = $sql.",$z=".getbz($ch);
				$i++;
				continue;
			}
			$sql = $sql.",$z=$ch[$i]";
			$i++;				
		}
		$sql = $sql." where xh='$iid'";
		mysql_query($sql);
	}
}
?>
			<table class="table table-bordered">
				<thead>
					<tr>
						<?
						include_once("../conn.php");
						$sql="select * from bkzd";
						$resultZd = mysql_query($sql);
						while($row = mysql_fetch_array($resultZd)){
							if($row['zd']!='yxmc'&&$row['zd']!='xslb'){
					?>
						<th><font color=black><?=$row['name']?></font></th>
						<?}}?>
					<th colspan="2" style="text-align: center;"><font color=black>操作</font></th>
					</tr>
				</thead>
	<tbody>
<?php 	
	
	$result = mysql_query("SELECT * FROM bachelor where xg=1");
	while($row = mysql_fetch_array($result))
		{
			$i=0;
			?>
	<tr>
		<td><font color=black><?=$row['xh'] ?></font></td>
		<td style="width: 60px"><font color=black><?=$row['xm'] ?></font></td>
		<td><font color=black><?=$row['yxg'][$i++] ?></font></td>
		<td><font color=black><?=$row['yxg'][$i++] ?></font></td>
		<td><font color=black><?=$row['yxg'][$i++] ?></font></td>
		<td><font color=black><?=$row['yxg'][$i++] ?></font></td>
		<td><font color=black><?=$row['yxg'][$i++] ?></font></td>
		<td><font color=black><?=$row['yxg'][$i++] ?></font></td>
		<td><font color=black><?=$row['yxg'][$i++] ?></font></td>
		<td><font color=black><?=$row['yxg'][$i++] ?></font></td>
		<td><font color=black><?=$row['yxg'][$i++] ?></font></td>
		<td><font color=black><?=$row['yxg'][$i++] ?></font></td>
		<td><font color=black><?=$row['yxg'][$i++] ?></font></td>
		<td><font color=black><?=$row['bz'] ?></font></td>
		<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
		<input type="text" name="change" class="hidden" value="<?=$row['yxg']?>"/>
		<input type="text" name="iid" class="hidden" value="<?=$row['xh']?>"/>
		<input type="text" name="message" class="hidden" value="pass"/>
		<th><button type="submit">通过</button></th>
		</form>
		
		<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
		<input type="text" name="change" class="hidden" value="<?=$row['yxg']?>"/>	
		<input type="text" name="message" class="hidden" value="reject"/>	
		<input type="text" name="iid" class="hidden" value="<?=$row['xh']?>"/>
		<th><button type="submit">拒绝</button></th>
		</form>
	</tr>
	
	<?}?>		
		</tbody>
		</table>
		</div>
	</div>
</div>
<?php }else{?>
<script>
	alert("请登录");
	window.location.href = '../login.html';
</script>
<?}?>
</body>
</html>
